/** 
	插件名称  :  monitor
	插件功能  :  监控器自定义插件
*/
define(['timepicker' ,'tree' ,'monitorTool'] ,function (timepicker ,tree ,monitorTool){
	return {
		monitorStatusChart : function (el ,opt,paramMap)
		{
			var time = opt.time;
			var data = opt.data;
			var statusMap = new HashMap();
			if(!paramMap){
				statusMap.put("-2" ,"bggrey");
				statusMap.put("-1" ,"bggrey");
				statusMap.put("0" ,"bggreen");
				statusMap.put("1" ,"bggrey");
				statusMap.put("2" ,"bgdeepblue");
				statusMap.put("3" ,"bgorange");
				statusMap.put("4" ,"bgred");
			}else {
				var keys = Object.keys(paramMap);
				for(var i=0;i<keys.length;i++){
					statusMap.put(keys[i],paramMap[keys[i]]);
				}
			}
			el.append("<span>名称："+opt.name+"</span>");
			var hourInt = parseInt(g_moment(time).format("HH"));
			for (var i = 24; i >= 1; i--) {
				el.append('<div><div></div><p>'+g_moment(time).subtract((i-1) ,"hours").format("HH")+'</p></div>');
			}
			// for (var i=0; i<=23; i++) {
			// 	el.append('<div><div></div><p>'+i+'</p></div>');
			// }
			if (data)
			{
				for (var i=0;i<data.length;i++)
				{
					for (var j = 0; j < data[i].length; j++) {
						el.append('<div class="scale-unit '+statusMap.get(data[i][j])+'"></div>');
					}
				}
			}
		},
		queryDialog : function (opt){
			$.ajax({
				type: "GET",
				url: "js/plugin/monitor/monitor.html",
				success :function(data)
				{
					g_dialog.dialog($(data).find("[id=query_monitor_template]"),{
						width:"500px",
						init:init,
						saveclick:save_click,
						title:"监控器查询"
					});
				}
			});
			function init(el)
			{
				// index_render_div(el.find("#mainIp") ,{type:"ip",id:"asertIP"});
			}
			function save_click(el ,saveObj)
			{
				opt.saveclick && opt.saveclick(saveObj,opt.selfEl,el);
				g_dialog.hide(el);
			}
		}
	};
});